package dataStructures;

/**
 * This interface provides method signatures for integer array based Heap data
 * structure
 * 
 * @author Vikas Bahirwani
 */
public interface IHeap {
	/**
	 * This method returns the parent of the given node
	 * 
	 * @param nodeIndex
	 * @return parent of the given node if nodeIndex<=heapSize and
	 *         parent(nodeIndex)<=heapSize; returns -1 otherwise.
	 */
	public int getParent(int nodeIndex);

	/**
	 * This method returns the left child of the given node.
	 * 
	 * @param nodeIndex
	 * @return left child of the given node if nodeIndex<= heapSize and
	 *         leftChild(nodeIndex)<=heapSize; returns -1 otherwise.
	 */
	public int getLeftChild(int nodeIndex);

	/**
	 * This method returns the right child of the given node.
	 * 
	 * @param nodeIndex
	 * @return right child of the given node if nodeIndex<= heapSize and
	 *         rightChild(nodeIndex)<=heapSize; returns -1 otherwise.
	 */
	public int getRightChild(int nodeIndex);

	/**
	 * 
	 * @return the index i such that elements from 0 to heapSize are follow the
	 *         heap property.
	 */
	public int getHeapSize();

	/**
	 * sets the heapSize property of the heap
	 * 
	 * @param i
	 */
	public void setHeapSize(int i);

	/**
	 * builds the heap out of array of elements
	 * 
	 * @return array of elements each of which follows the heap property.
	 */
	public int[] buildHeap();

	/**
	 * Assuming that left and right sub-trees of node nodeIndex follow the heap
	 * property, this method adjusts the location of node nodeIndex so that the
	 * resulting array of elements follows the heap property.
	 * 
	 */
	public void heapify(int nodeIndex);
}
